﻿using System;
using System.Collections.Generic;
using Assist;
using Autodesk.Revit.DB;
using HYOpeningCommon.DbOpening;
using HYOpeningDesignInput.Public;
using YJKRGeometry;

namespace HYOpeningDesignInput.DbOpeningCreatorFactory
{
	internal class DbWallStraightOpeningCreateFactory : DbWallOpeningCreatorFactory
	{
		public DbWallStraightOpeningCreateFactory(ref List<Document> lstDoc, WindowHandle handle, Dictionary<string, int> dicOpenProfileData) : base(ref lstDoc, handle, dicOpenProfileData)
		{
		}

		public override bool CreateDbOpening(MEPData mepData, ref LinkedList<DbOpeningBase> lstDbOpening)
		{
			base.SetWallOpeningChildObj(this);
			return base.CreateDbOpening(mepData, ref lstDbOpening);
		}

		public override void SetStraightOpeningData(ref OpeningData openingData)
		{
			openingData.m_directionCutObj = openingData.m_openingDirection;
		}

		public override void SetStraightOpeningData(double dAngle, double dHostWidth, double dCutWidthOrHeight, ref double dOpeningWidthOrHeight)
		{
			if (Geometry.IsEqual(dAngle, 0.0) || Geometry.IsEqual(Math.PI*.5, dAngle))
			{
				return;
			}
			dOpeningWidthOrHeight = dHostWidth / Math.Tan(dAngle) + dCutWidthOrHeight / Math.Sin(dAngle);
		}
	}
}
